package net.oschina.app.adapter.explore;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.base.BaseListAdapter;
import net.oschina.app.bean2.MoveDetailBean;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 张运湘 on 2017/1/18.
 */

public class EventDetilsAdapter extends BaseListAdapter<MoveDetailBean.PostBean> {
    private Context mContext;

    public EventDetilsAdapter(Context context) {
        mContext = context;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.fargment_eventsdatils, parent, false);
        RecyclerView.ViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MoveDetailBean.PostBean postBean =mList.get(position);
        ((MyViewHolder)holder).mTvEventTitle.setText(postBean.getTitle());
        ((MyViewHolder)holder).mTvEventStarttime.setText(postBean.getEvent().getStartTime());
        ((MyViewHolder)holder).mTvEventEndtime.setText(postBean.getEvent().getEndTime());
        ((MyViewHolder)holder).mTvEventAddress.setText(postBean.getEvent().getCity()+" "+postBean.getEvent().getSpot());
        //WebView加载数据
        ((MyViewHolder)holder).mWvEventdetils.loadUrl(postBean.getUrl());

    }

     class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_event_title)
        TextView mTvEventTitle;
        @BindView(R.id.tv_event_starttime)
        TextView mTvEventStarttime;
        @BindView(R.id.tv_event_endtime)
        TextView mTvEventEndtime;
        @BindView(R.id.tv_event_address)
        TextView mTvEventAddress;
        @BindView(R.id.iv_event_map)
        ImageView mIvEventMap;
        @BindView(R.id.btn)
        Button mBtn;
        @BindView(R.id.tv_event_datils)
        TextView mTvEventDatils;
        @BindView(R.id.wv_eventdetils)
        WebView mWvEventdetils;

        MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
